<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Robocup-denayer-project-a: read-only/trunk/source/strategie.cpp Bron Bestand</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Gegenereerd door Doxygen 1.7.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Zoeken');
--></script>
<script type="text/javascript">
function hasClass(ele,cls) {
  return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}

function addClass(ele,cls) {
  if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}

function removeClass(ele,cls) {
  if (hasClass(ele,cls)) {
    var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
    ele.className=ele.className.replace(reg,' ');
  }
}

function toggleVisibility(linkObj) {
 var base = linkObj.getAttribute('id');
 var summary = document.getElementById(base + '-summary');
 var content = document.getElementById(base + '-content');
 var trigger = document.getElementById(base + '-trigger');
 if ( hasClass(linkObj,'closed') ) {
   summary.style.display = 'none';
   content.style.display = 'block';
   trigger.src = 'open.png';
   removeClass(linkObj,'closed');
   addClass(linkObj,'opened');
 } else if ( hasClass(linkObj,'opened') ) {
   summary.style.display = 'block';
   content.style.display = 'none';
   trigger.src = 'closed.png';
   removeClass(linkObj,'opened');
   addClass(linkObj,'closed');
 }
 return false;
}
</script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Hoofd&nbsp;Pagina</span></a></li>
      <li><a href="annotated.html"><span>Klassen</span></a></li>
      <li class="current"><a href="files.html"><span>Bestanden</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
          <span class="left">
            <form id="FSearchBox" action="search.php" method="get">
              <img id="MSearchSelect" src="search/mag.png" alt=""/>
              <input type="text" id="MSearchField" name="query" value="Zoeken" size="20" accesskey="S" 
                     onfocus="searchBox.OnSearchFieldFocus(true)" 
                     onblur="searchBox.OnSearchFieldFocus(false)"/>
            </form>
          </span><span class="right"></span>
        </div>
      </li>
    </ul>
  </div>
  <div class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&nbsp;Lijst</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<h1>read-only/trunk/source/strategie.cpp</h1>  </div>
</div>
<div class="contents">
<a href="strategie_8cpp.html">Ga naar de documentatie van dit bestand.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00010"></a>00010 <span class="preprocessor">#include &quot;<a class="code" href="strategie_8h.html">strategie.h</a>&quot;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &quot;<a class="code" href="waypoint_8h.html">movingObject/waypoint.h</a>&quot;</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00015"></a>00015 <span class="keyword">using namespace </span>std;
<a name="l00016"></a>00016 
<a name="l00017"></a><a class="code" href="class_strategie.html#a91976dec8a210e69c4e49f2634cb005d">00017</a> <a class="code" href="class_strategie.html#a91976dec8a210e69c4e49f2634cb005d">Strategie::Strategie</a>() {
<a name="l00018"></a>00018         <span class="comment">// TODO Auto-generated constructor stub</span>
<a name="l00019"></a>00019     printf(<span class="stringliteral">&quot;Nieuwe strategie aangemaakt\n&quot;</span>);
<a name="l00020"></a>00020 
<a name="l00021"></a>00021     <span class="comment">// Start de visie!</span>
<a name="l00022"></a>00022     visie.<a class="code" href="class_thread.html#a1f53ee62bd30a7924186ef26150ce262" title="Thread::start();.">start</a>();
<a name="l00023"></a>00023 
<a name="l00024"></a>00024     <span class="comment">// Voeg objecten toe aan visie zodat hij deze volgt</span>
<a name="l00025"></a>00025 }
<a name="l00026"></a>00026 
<a name="l00027"></a><a class="code" href="class_strategie.html#aa8d26d0ee226f046d127ecc9677089bb">00027</a> <a class="code" href="class_strategie.html#aa8d26d0ee226f046d127ecc9677089bb">Strategie::~Strategie</a>() {
<a name="l00028"></a>00028         <span class="comment">// TODO Auto-generated destructor stub</span>
<a name="l00029"></a>00029 }
<a name="l00030"></a>00030 
<a name="l00034"></a><a class="code" href="class_strategie.html#a27783d4f2057840a62bb0621e418c4d3">00034</a> <a class="code" href="class_moving_object.html">MovingObject</a> <a class="code" href="class_strategie.html#a27783d4f2057840a62bb0621e418c4d3" title="Get eigen robot.">Strategie::getZelf</a>(<span class="keywordtype">void</span>) {
<a name="l00035"></a>00035         <span class="comment">// lock mutex, to prevent writing and reading zelf at the same time</span>
<a name="l00036"></a>00036         pthread_mutex_lock(&amp;zelfMutex);
<a name="l00037"></a>00037 
<a name="l00038"></a>00038         <span class="comment">// Haal waypoint</span>
<a name="l00039"></a>00039         <a class="code" href="class_moving_object.html">MovingObject</a> ret = this-&gt;zelf;
<a name="l00040"></a>00040 
<a name="l00041"></a>00041         <span class="comment">// Unlock mutex</span>
<a name="l00042"></a>00042         pthread_mutex_unlock(&amp;zelfMutex);
<a name="l00043"></a>00043 
<a name="l00044"></a>00044         <span class="keywordflow">return</span> ret;
<a name="l00045"></a>00045 }
<a name="l00046"></a>00046 
<a name="l00052"></a><a class="code" href="class_strategie.html#a084d72e389b5961bb991f3c69cab09e3">00052</a> <span class="keywordtype">void</span> <a class="code" href="class_strategie.html#a084d72e389b5961bb991f3c69cab09e3" title="Probeer de bal te onderscheppen.">Strategie::onderschepBal</a>(<span class="keywordtype">double</span> tijd){
<a name="l00053"></a>00053     printf(<span class="stringliteral">&quot;Ik ga onderscheppen!\n&quot;</span>);
<a name="l00054"></a>00054     <span class="comment">/* // Updates gaan automatisch gaan</span>
<a name="l00055"></a>00055 <span class="comment">    this-&gt;visie.updatePosition(zelf);</span>
<a name="l00056"></a>00056 <span class="comment">    this-&gt;visie.updatePosition(bal);</span>
<a name="l00057"></a>00057 <span class="comment">     */</span>
<a name="l00058"></a>00058 
<a name="l00059"></a>00059     <span class="comment">//  WayPoint snijpunt = bal.getWpIntersection(zelf);</span>
<a name="l00060"></a>00060     <span class="comment">// Bereken waar de bal is na die bepaalde tijd</span>
<a name="l00061"></a>00061     <a class="code" href="class_way_point.html">WayPoint</a> snijpunt = bal.<a class="code" href="class_moving_object.html#a6e7fed1c00f986d7f8a87545f43ba3fa">getWpNext</a>(tijd);
<a name="l00062"></a>00062 
<a name="l00063"></a>00063     <span class="comment">/*</span>
<a name="l00064"></a>00064 <span class="comment">     * @TODO Nakijken of het binnen het veld ligt!</span>
<a name="l00065"></a>00065 <span class="comment">     */</span>
<a name="l00066"></a>00066     
<a name="l00067"></a>00067     printf(<span class="stringliteral">&quot;Ik ga sturing aanspreken\n&quot;</span>);
<a name="l00068"></a>00068 
<a name="l00069"></a>00069     <span class="comment">// Theta-180° want je wil in recht tegenover de bal komen te liggen</span>
<a name="l00070"></a>00070     sturing.<a class="code" href="class_besturing.html#a5fc2f2acafc8f4f26447ca3f529a5099" title="ga naar punt en draai u dan richting angle">goTo</a>(snijpunt.<a class="code" href="class_way_point.html#af8e925a0c05154820837e21852cf08a5" title="Get X-coordinaat.">getX</a>(),snijpunt.<a class="code" href="class_way_point.html#abf3b2046af024d6b2c50aacc82175b05">getY</a>(),snijpunt.<a class="code" href="class_way_point.html#a4e0114e5291cc0039c6a5b505d0103cd">getTheta</a>() - M_PI);
<a name="l00071"></a>00071     printf(<span class="stringliteral">&quot;Ik ben klaar met de sturing aanspreken\n&quot;</span>);
<a name="l00072"></a>00072 
<a name="l00073"></a>00073     printf(<span class="stringliteral">&quot;Kben klaar met onderscheppen van bal!\n&quot;</span>);
<a name="l00074"></a>00074 }
<a name="l00075"></a>00075 
<a name="l00080"></a><a class="code" href="class_strategie.html#a831db3772f226db97003c4325ea6d732">00080</a> <span class="keywordtype">void</span> <a class="code" href="class_strategie.html#a831db3772f226db97003c4325ea6d732" title="Rij recht naar de bal en vang hem.">Strategie::rijRechtNaarBal</a>(<span class="keywordtype">void</span>)
<a name="l00081"></a>00081 {
<a name="l00082"></a>00082         <span class="keywordflow">return</span> <a class="code" href="class_strategie.html#a084d72e389b5961bb991f3c69cab09e3" title="Probeer de bal te onderscheppen.">onderschepBal</a>(0);
<a name="l00083"></a>00083 }
<a name="l00084"></a>00084 
<a name="l00089"></a><a class="code" href="class_strategie.html#ac475eb687f7c5043bd317f6287a33e5e">00089</a> <span class="keywordtype">void</span> <a class="code" href="class_strategie.html#ac475eb687f7c5043bd317f6287a33e5e" title="Rij in een vierkantje.">Strategie::rijVierkant</a>(<span class="keywordtype">int</span> size)
<a name="l00090"></a>00090 {
<a name="l00091"></a>00091         <span class="comment">// start op 0,0,0)</span>
<a name="l00092"></a>00092         sturing.<a class="code" href="class_besturing.html#a5fc2f2acafc8f4f26447ca3f529a5099" title="ga naar punt en draai u dan richting angle">goTo</a>(0,0,0);
<a name="l00093"></a>00093         sturing.<a class="code" href="class_besturing.html#a5fc2f2acafc8f4f26447ca3f529a5099" title="ga naar punt en draai u dan richting angle">goTo</a>(size,0,0);
<a name="l00094"></a>00094         sturing.<a class="code" href="class_besturing.html#a5fc2f2acafc8f4f26447ca3f529a5099" title="ga naar punt en draai u dan richting angle">goTo</a>(size,size,0);
<a name="l00095"></a>00095         sturing.<a class="code" href="class_besturing.html#a5fc2f2acafc8f4f26447ca3f529a5099" title="ga naar punt en draai u dan richting angle">goTo</a>(0,size,0);
<a name="l00096"></a>00096         sturing.<a class="code" href="class_besturing.html#a5fc2f2acafc8f4f26447ca3f529a5099" title="ga naar punt en draai u dan richting angle">goTo</a>(0,0,0);
<a name="l00097"></a>00097 }
<a name="l00098"></a>00098 
<a name="l00099"></a>00099 
<a name="l00100"></a>00100 
<a name="l00101"></a><a class="code" href="class_strategie.html#a2950616c75da0213603c6cb172390240">00101</a> <span class="keywordtype">void</span> <a class="code" href="class_strategie.html#a2950616c75da0213603c6cb172390240">Strategie::doeTest</a>(<span class="keywordtype">void</span>){
<a name="l00102"></a>00102     printf(<span class="stringliteral">&quot;DoeTest!\n&quot;</span>);
<a name="l00103"></a>00103 
<a name="l00104"></a>00104     <span class="keywordtype">int</span> i;
<a name="l00105"></a>00105     <span class="keywordflow">for</span>(i=0;i&lt;20;i++)
<a name="l00106"></a>00106     {
<a name="l00107"></a>00107         this-&gt;visie.<a class="code" href="class_vision.html#aec79e4b47335403f7548dcc99bbd7f07" title="update waypoints van het bewegend object">updatePosition</a>(zelf);
<a name="l00108"></a>00108         printf(<span class="stringliteral">&quot;%d\n&quot;</span>,i);
<a name="l00109"></a>00109         printf(<span class="stringliteral">&quot;Strategie: %d: %d   Y: %d    \n&quot;</span>,
<a name="l00110"></a>00110                 i,
<a name="l00111"></a>00111                 zelf.<a class="code" href="class_moving_object.html#a51fd06046cbdff9cd1100b80e5b7e951">getWp</a>().<a class="code" href="class_way_point.html#af8e925a0c05154820837e21852cf08a5" title="Get X-coordinaat.">getX</a>(),
<a name="l00112"></a>00112                 zelf.<a class="code" href="class_moving_object.html#a51fd06046cbdff9cd1100b80e5b7e951">getWp</a>().<a class="code" href="class_way_point.html#abf3b2046af024d6b2c50aacc82175b05">getY</a>());
<a name="l00113"></a>00113         sleep(1);
<a name="l00114"></a>00114     }
<a name="l00115"></a>00115 }
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Gegenereerd op Do 19 Mei 2011 10:15:29 voor Robocup-denayer-project-a door&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
